﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Xml.Linq;

namespace Press.MVC.Data
{
    public class Blog
    {

        public int ID { get; set; }    
        
        /// <summary>
        /// Name - The Blog Name (required)
        /// </summary>
        public string Name { get; set; }   
        
        /// <summary>
        /// SubTitle - The Blog Sub Title (not required)
        /// </summary>
        public string SubTitle { get; set; }        
        
        /// <summary>
        /// ShortName - The Blog sub domain/subdirectory http://shortname.domain.tld or http://www.domain.tld/shortname (required)
        /// </summary>
        public string ShortName { get; set; }        
        
        /// <summary>
        /// IsActive - Specifies whether the Blog is active on the Site. In active until the Blog is activated (required)
        /// </summary>
        public bool IsActive { get; set; }

        public XElement Settings { get; set; }        

        public LazyList<PostCategory> PostCategories { get; set; }        
        public LazyList<Post> Posts { get; set; }                

        #region object overrides
        public override bool Equals(object obj)
        {
            if (obj is Blog)
            {
                Blog compareTo = (Blog)obj;
                return compareTo.ID == this.ID;
            }
            else
            {
                return base.Equals(obj);
            }
        }

        public override string ToString()
        {
            return this.Name;
        }
        public override int GetHashCode()
        {
            return this.ID.GetHashCode();
        }
        #endregion
    }
}
